package org.sevaapp.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model; // import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.sevaapp.domain.Lab;

@Service
public class LabServiceImpl implements LabService {

	private static final Log log = LogFactory.getLog(LabServiceImpl.class);

	@Autowired
	private Lab domainObj;

	/**
	 * Validation method implementation.
	 */
	public boolean validate(Lab domainObj) {
		return true;
	}

	@RequestMapping("/labs/{labId}")
	// public String getLab(@PathVariable long labId, Model model) {
	public void getLab(Integer domainObjId) {
		log.debug("getLab method called.");
	}

	public void addNewLab(Lab inputData) {
		log.debug("addNewLab() method called.");
		log.debug("Domain Object Data:" + inputData.toString());

		// Call validate method
		boolean isValidData = validate(inputData);
		log.debug("isValidData=" + isValidData);
		if (isValidData) {
			if (inputData.getId() == null) {
				// New record, call add method
				domainObj.add(inputData);
			} else {
				// Existing record, call edit method
				domainObj.update(inputData);
			}
		}
	}

	public void updateLab(Lab inputData) {
		log.debug("updateLab() method called.");
		log.debug("Domain Object Data:" + inputData.toString());
	}
}
